//SamXIAO
#include <bits/stdc++.h>
using namespace std;
#define PI 3.1415926
#define   SQUARE(x) ((x)*(x))
//double SQUARE(double x) { return x*x;}
#define N_MAX 987654321
#define N_MIN -N_MAX
int f[20086][4];

void w1()
{
	int n, x, y, ans=-1;
	scanf("%d", &n);
	for(int i=1; i<=n; i++){
		scanf("%d%d%d%d", &f[i][0], &f[i][1], &f[i][2], &f[i][3]);
  }
  scanf("%d%d", &x, &y);
	for(int i=1; i<=n; i++){
		if(  f[i][0] <= x && x <= f[i][0] + f[i][2]
			&& f[i][1] <= y && y <= f[i][1] + f[i][3]){
				ans = i;
		}
  }
  printf("%d", ans);
}

int main()
{
	w1();
  return 0;
}
